<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>运动项目添加</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" type="text/css" href="../css/style.css"/>
</head>

<body>
<div id="wrap">
    <div id="top_content">
        <div id="header">
            <div id="rightheader"><p id="current_time"><br/></p></div>
            <div id="topheader">
                <h1 id="title">
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="adhomepage.html">首页</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<a href="modifyScore.html">评分</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="scoreCount.html">成绩统计</a>
                </h1>
            </div>
            <div id="navigation"></div>
        </div>
        <div id="content">
            <p id="whereami"></p>
            <h1>添加运动项目:</h1>
            <form>
                <table cellpadding="0" cellspacing="0" border="0" class="form_table">
                    <tr>
                        <td valign="middle" align="right">项目名称:</td>
                        <td valign="middle" align="left">
                            <input type="text" class="inputgri" id="name"/>
                        </td>
                    </tr>
                    <tr>
                        <td valign="middle" align="right">总名额:</td>
                        <td valign="middle" align="left">
                            <input type="text" class="inputgri" id="quota"/>
                        </td>
                    </tr>
                    <tr>
                        <td valign="middle" align="right">比赛时间:</td>
                        <td valign="middle" align="left">
                            <input type="datetime-local" class="inputgri" id="startTime"/>
                        </td>
                    </tr>
                    <tr>
                        <td valign="middle" align="right">比赛地点:</td>
                        <td valign="middle" align="left">
                            <input type="text" class="inputgri" id="location"/>
                        </td>
                    </tr>
                </table>
                <p>
                    <input type="button" class="button" onclick="addEvent()" value="添加"/>
                </p>
            </form>
        </div>
    </div>
    <div id="footer">
        <div id="footer_bg">ABC@126.com</div>
    </div>
</div>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript">

    $("#current_time").text(new Date().toLocaleDateString());

    function addEvent() {
        $.get({
            url: "/event/add",
            data: {
                "name":       $("#name").val(),
                "quota":      $("#quota").val(),
                "startTime":  $("#startTime").val().replace("T", " "),
                "location":   $("#location").val(),
            },
            success(data) {
                alert(data.message);
                if (data.code == 200) window.location.href = "adhomepage.html";
            },
            error(data) {
                alert("网络请求异常");
                console.log(data);
            }
        });
    }
</script>
</body>
</html>
